import Vue from "vue"
import VueRouter from "vue-router"
import Layout from "../views/Layout.vue"

Vue.use(VueRouter)

// 通用页面, 这里的配置不需要权限
export const constRouter = [
  {
    path: "/",
    component: Layout,
    redirect: "/home",
    meta: {
      title: "布局", //导航菜单项标题
      icon: "xx", //导航菜单图标
    },
    children: [
      {
        path: "home",
        name: "Home",
        component: () => import("../views/Home.vue"),
        meta: {
          title: "Home",
          icon: "qq",
        },
      },
    ],
  },
  {
    path: "/login",
    name: "Login",
    component: () => import("../views/Login.vue"),
    hidden: true, //导航菜单忽略选项
  },
  {
    path: "*",
    name: "NotFound",
    component: () => import("../views/NotFound.vue"),
    hidden: true, //导航菜单忽略选项
  },
]

// 动态路由
export const asyncRoutes = [
  {
    path: "/about",
    component: () => import("@/views/About.vue"),
    name: "About",
    meta: {
      title: "关于",
      icon: "xx",
      roles: ["admin", "editor"], //角色权限配置
    },
  },
]

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes: constRouter,
})

export default router
